package com.study.mall.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo {

    public static void main11(String[] args) {

        //匿名内部类
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("Demo.run");
                System.out.println("Demo.run");
            }
        }).start();

        //Lambda
        new Thread(() -> {
            System.out.println("Demo.run");
            System.out.println("Demo.run");
        }).start();
    }



    public static void main3(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> task = new FutureTask<String>(new MyCallable());
        //new Thread(task).start();
        Thread thread = new Thread(task);
        thread.start();
        System.out.println(task.get());
    }

    public static void main2(String[] args) {
        Thread thread = new Thread(new MyRunnable(), "aaa");
        thread.start();
    }

    public static void main(String[] args) {
        //主线程
        System.out.println(Thread.currentThread().getName());
        MyThread myThread = new MyThread();
        myThread.start();
        System.out.println("Demo.main");
    }
}
